package com.tree;


import java.util.*;

/**
 * @author 代廷波
 * @className: TreeUtils
 * @description:
 * @create 2018/11/8 0008-16:57
 **/
public class TreeUtils {

    public <T extends Tree> List<T> fromTree(List<T> list){
        List<T> tree = new ArrayList<>();
         Boolean mak=false;
        for (T parentObj : tree) {
            mak=false;
            for (T childrenObj : tree) {
                if (parentObj.getPid() != null && parentObj.getPid().equals(childrenObj.getId()));{
                    if (childrenObj.getChildren()==null){
                        childrenObj.setChildren(new ArrayList<>());
                    }
                    childrenObj.getChildren().add(parentObj);
                }

            }
        }

        return tree;
    }
}
